package com.sxy.controller;

import com.sxy.pojo.Book;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 宋鑫宇
 * @version 1.0
 */
@RestController
@RequestMapping("/books")
public class BookController {

    @PostMapping
    public String save(@RequestBody Book book){
        System.out.println("book save...." + book);
        return "{'module':book save}";
    }

    @GetMapping
    public List<Book> getAll(){
        Book book1 = new Book();
        book1.setId(1);
        book1.setName("SpringMvc入门教程");
        book1.setType("计算机");
        book1.setDescription("入门");

        Book book2 = new Book();
        book2.setId(2);
        book2.setName("SpringMvc入门教程");
        book2.setType("计算机");
        book2.setDescription("进阶");

        List<Book> books = new ArrayList<>();
        books.add(book1);
        books.add(book2);

        return books;
    }
}
